/*****************************************************************************/
/* File: Drawable.h                                                          */
/* Author: Ozon                                                              */
/*                                                                           */
/* Description:																 */
/*	Class that is ascendant for all drawable objects.						 */
/*****************************************************************************/
#pragma once

#include <windows.h>

#include <gl\gl.h>
#include <gl\glu.h>
#include <vector>
#include <algorithm>

#include "SoundManager.h"
#include "Common.h"

using namespace std;

class CLevel;
class CPhysics;
class CDrawList;
class CModel;
class CRenderer;

class CDrawable
{
protected:
	dGeomID m_geom;
	dBodyID m_body;
	dMass m_mass;
	bool m_bMarked;	//set if marked to remove

	CModel* m_pModel;	//3D model of an object

	void SetTransform(double dMatrix[16], const double dPos[3], const double dRot[12]);
	virtual int SetupMatrices();

	static CPhysics* m_pPhysics;
	static CDrawList* m_pDrawList;
	static CLevel* m_pLevel;
	static CRenderer* m_pRenderer;

	SMaterial m_matMaterial;

public:
	CDrawable();
	virtual ~CDrawable(void);

	virtual int Draw() = 0;
	virtual int Update(){return 0;}

	virtual int GetType() = 0;	//every object should define it's own type - types given in Common.h
	virtual void Remove(){m_bMarked = true;}

	const double* GetPosition() {return dBodyGetPosition(m_body);}
	bool IsMarked(){return m_bMarked;}

	void EnableBody() { dBodyEnable(m_body); }

	static void SetLevel(CLevel* pLevel);
	static void SetPhysics(CPhysics* pPhysics);
	static void SetDrawList(CDrawList* pDrawList);
	static void SetRenderer(CRenderer* pRenderer);

	//const double* GetRotation(){return dBodyGetRotation(m_body);}
	//virtual int Spawn() = 0;
	//virtual int Remove() = 0;

	CSoundManager* m_pSoundManager;
};
